<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        i{
            font-style: normal;
        }
        h1{
            font-size: 20px;
            line-height: 20px;
            margin-bottom: 20px;
        }
        .box{
            width: 280px;
            height: 480px;
            border:solid 1px pink;
            margin: 30px auto;
            text-align: center;
        }
        .box img{
            width: 200px;
            height: 300px;
            margin-top: 20px;
        }
        .box p{
            display: block;
            font-size: 14px;
            line-height: 16x;
            color: #ccc;
            margin-bottom: 5px;
        }
        .con_box{
            width: 280px;
            height: 30px;
            margin-left: 55px;
            margin-bottom: 10px;
        }
        .con_box label{
            float: left;
            font-size: 16px;
            color: #ccc;
        }
        .con_box #btn1{
            display: inline-block;
            width: 24px;
            height: 24px;
            border: 0;
            color: #666;
            background: #ccc;
            float: left;
            outline: none;
        }
        .con_box #btn2{
            display: inline-block;
            width: 24px;
            height: 24px;
            border: 0;
            background: #ccc;
            color: #666;
            float: left;
            outline: none;
        }
        .con_box #txt{
            width: 27px;
            height: 24px;
            padding-left: 23px;
            border: 0;
            float: left;
        }
        #con{
            width: 100px;
            height: 20px;
        }
        .box span{
            display: block;
        }
    </style>
</head>
<body>
    <div class="box">
        <img src="./2.jpg" alt="">
        <p>纪梵希 小羊皮口红304</p>
        <h1>￥<i id="danjia">340</i></h1>
        <div class="con_box">
            <label for="">数量：</label>
            <div class="con">
                <input type="button" value="-" id="btn1">
                <input type="text" id="txt" value="0" disabled>
                <input type="button" value="+" id="btn2">
    
            </div>

        </div>
        <span>总价￥：<i id="zongjia">0</i></span>
    </div>
</body>
<script>
    var obtn1 = document.getElementById("btn1");
    var obtn2 = document.getElementById("btn2");
    var otxt = document.getElementById("txt");
    obtn1.onclick = function(){
        var otxt = document.getElementById("txt");
        if(Number(otxt.value) === 0){
            otxt.value = 0;
        }else{
            otxt.value = Number(otxt.value)-1;

        }
        zongjia.innerHTML = otxt.value * danjia.innerHTML;
    }
    obtn2.onclick = function(){
        var otxt = document.getElementById("txt");
        otxt.value = Number(otxt.value)+1;
        zongjia.innerHTML = otxt.value * danjia.innerHTML;
    }
</script>

</script>
</html>